<template>
  <div class="wrapper">
    <div class="editName">
      <div class="header">
        <span class="return" @click="back()">取消</span>群介绍<span class="send" @click="save()">完成</span>
      </div>
      <div class="setNameLine"></div>
      <input type="text" v-model="Introduction" class="input">
    </div>
  </div>
</template>
<script>
import Client from '../../assets/js/common';
import { Toast } from 'mint-ui';
import { Popup } from 'mint-ui';
import { Actionsheet } from 'mint-ui';
import { MessageBox } from 'mint-ui';
import {checkStatus} from '../../assets/js/login';
export default {
  data () {
    return {
      loginInfo: {},
      Introduction: '',
      groupData: {}
    }
  },
  created () {
    checkStatus((loginInfo) => {
      this.loginInfo = loginInfo;
      console.log(Client.getStore("ClickCurrentGroupData"));
      this.groupData = Client.getStore("ClickCurrentGroupData");
      this.groupId =  this.groupData.GroupId;
      this.Introduction = this.groupData.Introduction;
    });
  },
  methods: {
    back() {
      this.$router.back();
    },

    save() {
      //修改群资料
        if (webim.Tool.getStrBytes(this.Introduction) > 150) {
            Toast('您输入的群组简介超出限制(最长50个汉字)');
            return;
        }
        let options = {
            'GroupId': this.groupId,
            'Introduction': this.Introduction,
        };
          webim.modifyGroupBaseInfo(
                options,
                (resp) => {
                    MessageBox.alert('修改群资料成功');
                    this.changeStorage('ClickCurrentGroupData', 'Introduction', this.Introduction, null);
                    this.back();

                },
                (err) => {
                    // alert(err.ErrorInfo);
                    Client.errInfo();
                }
        );  
    },

    changeStorage(storeName, field, changeData, save) {
       let createData = Client.getStore(storeName);
       if(!createData) return;
       createData[field] = changeData;
       Client.setStore(storeName, createData);
       if(save) {
         save = Client.getStore(storeName);
       }
    },
  }  
}
</script>

<style lang="less" scoped>
.editName{
        width: 100%;
        height: 100%;
        background: #F5F5F5;
        .setNameLine {
          height: 0.21rem;
        }
        .input {
          width: 100%;
          height: 0.5rem;
          padding: 0 0.15rem;
          background-color: white;
          color: #4A4A4A;
          font-size: 0.14rem;
          outline: none;
          font-weight: 400;
          border: none;
          box-sizing: border-box;
        }
      }
  .wrapper {
    .header {
      width: 3.75rem;
      height: 0.5rem;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      font-size: 0.16rem;
      border-bottom: 1px solid #f4f4f4;
      background-color: white!important;
      .return {
        color: #4A4A4A;
        font-size: 0.16rem;
        position: absolute;
        left: 0.15rem;
      }
      .send {
        color: #4A4A4A;
        font-size: 0.16rem;
        position: absolute;
        right: 0.15rem;
      }
    }
    
  }

</style>

